package cn.tedu.micro.demo.device.service.impl;

import cn.tedu.micro.demo.common.vo.GunInfoVO;
import cn.tedu.micro.demo.device.mapper.GunInfoMapper;
import cn.tedu.micro.demo.device.po.GunInfoPO;
import cn.tedu.micro.demo.device.service.DeviceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class DeviceServiceImpl implements DeviceService {
    @Autowired
    private GunInfoMapper gunInfoMapper;
    @Override
    public GunInfoVO checkGunStatus(Integer id) {
        GunInfoVO vo=null;
        //1.调用持久层 读取枪完整po
        //select * from gun_info where id=?
        GunInfoPO po = gunInfoMapper.selectById(id);
        //判断 po非空
        if (po!=null){
            //2.封装vo
            log.info("当前查询结果不为空");
            vo=new GunInfoVO();
            BeanUtils.copyProperties(po,vo);
        }else{
            log.info("当前查询结果为空");
        }
        return vo;
    }
}
